using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;

namespace LyonMag
{
    public partial class Theatre : PhoneApplicationPage
    {
        string id = string.Empty;
        private App app = App.Current as App;
        string name = string.Empty;
        List<LyonMag.Cinema.innercinema> obj_Tlist = new List<Cinema.innercinema>();
        public Theatre()
        {
            InitializeComponent();
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            try
            {
                NavigationContext.QueryString.TryGetValue("id", out id);
                for(int i=0;i<app.lst_Cinema_comment.Count();i++)
                {
                    if(app.lst_Cinema_comment[i].Id==id)
                    {
                        txtTitle.Text = app.lst_Cinema_comment[i].Title;
                        name = app.lst_Cinema_comment[i].Title;
                        for(int k=0;k<app.lst_Cinema_comment[i].cinema_details.Count();k++)
                        {
                            obj_Tlist.Add(new Cinema.innercinema() { Cine_nom = app.lst_Cinema_comment[i].cinema_details[k].Cine_nom,Cine_horaires=app.lst_Cinema_comment[i].cinema_details[k].Cine_horaires,Cinemaid=app.lst_Cinema_comment[i].cinema_details[k].Cinemaid });
                        }
                    }
                }
                lstTheatres.ItemsSource = obj_Tlist;
                
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
            }
        }

        private void lstTheatres_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                LyonMag.Cinema.innercinema obj_Tlist = new Cinema.innercinema();
                obj_Tlist = lstTheatres.SelectedItem as Cinema.innercinema;
                NavigationService.Navigate(new Uri("/TTimings.xaml?name=" + name + "&holaries=" + obj_Tlist.Cine_horaires + "", UriKind.RelativeOrAbsolute));
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
            }
        }
    }
}